package top.leyi.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import top.leyi.entity.SQLUtil;
import top.leyi.entity.pushAndColle.Collection0;

import java.util.List;

/**
 * @param
 * dest 目标人物的id
 * original 产生的任务的id
 * type 产生任务的类型的名称（class）
 */
public interface CollectionMapper {

    @Select("SELECT id,type,original,dest,time FROM collection where dest = #{id} and is_delete = 0 LIMIT #{limit} OFFSET #{offset}")
    public List<Collection0> getOwnColl(SQLUtil util);

    @Insert("INSERT INTO collection (type,original,dest) VALUES (#{type}, #{original}, #{dest})")
    public void addColl(Collection0 collection0);

    @Delete("UPDATE collection  SET is_delete = 1 WHERE id = #{id}")
    public void removeColl(Collection0 collection0);

    @Select("SELECT id FROM collection WHERE original = #{original} and dest = #{dest} and is_delete = 0")
    public Integer queryHasCol(int original, int dest);
}